#Boa:Dialog:serviceDlg

import wx
from common import *

def create(parent):
    return serviceDlg(parent)

[wxID_SERVICEDLG, wxID_SERVICEDLGCANCLE, wxID_SERVICEDLGDEPARTURE,
 wxID_SERVICEDLGDEPARTURELOCATION, wxID_SERVICEDLGDEPARTURETIME,
 wxID_SERVICEDLGDESTINATIONLOCATION, wxID_SERVICEDLGDESTINATIONTIME,
 wxID_SERVICEDLGNOTEBOOK1, wxID_SERVICEDLGPANEL1, wxID_SERVICEDLGPANEL2,
 wxID_SERVICEDLGSCROLLEDWINDOW1, wxID_SERVICEDLGSCROLLEDWINDOW2,
 wxID_SERVICEDLGSCROLLEDWINDOW3, wxID_SERVICEDLGSTATICTEXT1,
 wxID_SERVICEDLGSTATICTEXT2, wxID_SERVICEDLGSTATICTEXT3,
 wxID_SERVICEDLGSTATICTEXT4, wxID_SERVICEDLGSTATICTEXT5,
 wxID_SERVICEDLGSUBMIT, wxID_SERVICEDLGTIMEOUT,
] = [wx.NewId() for _init_ctrls in range(20)]

class serviceDlg(wx.Dialog):
    def _init_coll_notebook1_Pages(self, parent):
        # generated method, don't edit

        parent.AddPage(imageId=-1, page=self.scrolledWindow1, select=True,
              text=u'Service')
        parent.AddPage(imageId=-1, page=self.scrolledWindow2, select=False,
              text=u'Driver')
        parent.AddPage(imageId=-1, page=self.scrolledWindow3, select=False,
              text=u'Passanger')

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_SERVICEDLG, name=u'serviceDlg',
              parent=prnt, pos=wx.Point(426, 180), size=wx.Size(540, 463),
              style=wx.DEFAULT_DIALOG_STYLE, title=u'Service')
        self.SetClientSize(wx.Size(522, 418))

        self.notebook1 = wx.Notebook(id=wxID_SERVICEDLGNOTEBOOK1,
              name='notebook1', parent=self, pos=wx.Point(8, 8),
              size=wx.Size(504, 360), style=0)

        self.scrolledWindow1 = wx.ScrolledWindow(id=wxID_SERVICEDLGSCROLLEDWINDOW1,
              name='scrolledWindow1', parent=self.notebook1, pos=wx.Point(0, 0),
              size=wx.Size(496, 329), style=wx.HSCROLL | wx.VSCROLL)

        self.scrolledWindow2 = wx.ScrolledWindow(id=wxID_SERVICEDLGSCROLLEDWINDOW2,
              name='scrolledWindow2', parent=self.notebook1, pos=wx.Point(0, 0),
              size=wx.Size(496, 329), style=wx.HSCROLL | wx.VSCROLL)

        self.scrolledWindow3 = wx.ScrolledWindow(id=wxID_SERVICEDLGSCROLLEDWINDOW3,
              name='scrolledWindow3', parent=self.notebook1, pos=wx.Point(0, 0),
              size=wx.Size(496, 329), style=wx.HSCROLL | wx.VSCROLL)

        self.departure = wx.Panel(id=wxID_SERVICEDLGDEPARTURE,
              name=u'departure', parent=self.scrolledWindow1, pos=wx.Point(0,
              120), size=wx.Size(480, 100), style=wx.TAB_TRAVERSAL)

        self.panel1 = wx.Panel(id=wxID_SERVICEDLGPANEL1, name='panel1',
              parent=self.scrolledWindow1, pos=wx.Point(0, 248),
              size=wx.Size(488, 56), style=wx.TAB_TRAVERSAL)

        self.DestinationLocation = wx.Choice(choices=["Pudong ariport",
              "Hongqiao Airport", "West Train station", "Central Park"],
              id=wxID_SERVICEDLGDESTINATIONLOCATION,
              name=u'DestinationLocation', parent=self.departure,
              pos=wx.Point(8, 40), size=wx.Size(140, 26), style=0)
        self.DestinationLocation.SetSelection(0)

        self.DestinationTime = wx.Choice(choices=["<60 minutes"],
              id=wxID_SERVICEDLGDESTINATIONTIME, name=u'DestinationTime',
              parent=self.departure, pos=wx.Point(264, 40), size=wx.Size(140,
              26), style=0)

        self.staticText2 = wx.StaticText(id=wxID_SERVICEDLGSTATICTEXT2,
              label=u'DestinationTime', name='staticText2',
              parent=self.departure, pos=wx.Point(272, 8), size=wx.Size(104,
              18), style=0)

        self.staticText1 = wx.StaticText(id=wxID_SERVICEDLGSTATICTEXT1,
              label=u'DestinationLocation', name='staticText1',
              parent=self.departure, pos=wx.Point(8, 8), size=wx.Size(124, 18),
              style=0)

        self.panel2 = wx.Panel(id=wxID_SERVICEDLGPANEL2, name='panel2',
              parent=self.scrolledWindow1, pos=wx.Point(0, 8), size=wx.Size(480,
              100), style=wx.TAB_TRAVERSAL)

        self.staticText4 = wx.StaticText(id=wxID_SERVICEDLGSTATICTEXT4,
              label=u'DepartureTime', name='staticText4', parent=self.panel2,
              pos=wx.Point(312, 0), size=wx.Size(98, 18), style=0)

        self.DepartureLocation = wx.Choice(choices=["NO.120 East Guilin St",
              "NO.948 Lujiazui ring RD", "NO.775 Pusan RD"],
              id=wxID_SERVICEDLGDEPARTURELOCATION, name=u'DepartureLocation',
              parent=self.panel2, pos=wx.Point(8, 24), size=wx.Size(264, 26),
              style=0)
        self.DepartureLocation.SetSelection(0)

        self.DepartureTime = wx.Choice(choices=["<15 minutes", "<30 minutes"],
              id=wxID_SERVICEDLGDEPARTURETIME, name=u'DepartureTime',
              parent=self.panel2, pos=wx.Point(312, 24), size=wx.Size(140, 26),
              style=0)
        self.DepartureTime.SetSelection(0)

        self.staticText3 = wx.StaticText(id=wxID_SERVICEDLGSTATICTEXT3,
              label=u'DepartureLocation', name='staticText3',
              parent=self.panel2, pos=wx.Point(8, 0), size=wx.Size(118, 18),
              style=0)

        self.submit = wx.Button(id=wx.ID_OK, label=u'submit', name=u'submit',
              parent=self, pos=wx.Point(88, 376), size=wx.Size(100, 31),
              style=0)
        self.submit.Bind(wx.EVT_BUTTON, self.OnSubmitButton, id=wx.ID_OK)

        self.cancle = wx.Button(id=wx.ID_CANCEL, label=u'cancel',
              name=u'cancle', parent=self, pos=wx.Point(320, 376),
              size=wx.Size(100, 31), style=0)

        self.timeout = wx.TextCtrl(id=wxID_SERVICEDLGTIMEOUT, name=u'timeout',
              parent=self.panel2, pos=wx.Point(64, 72), size=wx.Size(100, 26),
              style=0, value=u'900')

        self.staticText5 = wx.StaticText(id=wxID_SERVICEDLGSTATICTEXT5,
              label=u'timeout', name='staticText5', parent=self.panel2,
              pos=wx.Point(8, 72), size=wx.Size(49, 18), style=0)

        self._init_coll_notebook1_Pages(self.notebook1)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.parent = parent

    def OnSubmitButton(self, event):
        event.Skip()
        departureLocation = (0,0,self.DepartureLocation.Items[self.DepartureLocation.Selection])
        departureTime = getLocalTime(time.time() + (self.DepartureTime.Selection+1)*900)
        status  = EST_BOOKING
        timeout = int(self.timeout.Value)
        destinationLocation = (0,0,self.DestinationLocation.Items[self.DestinationLocation.Selection])
        destinationTime = None
        price = None
        self.parent.Publish(departureLocation,departureTime,status,timeout,destinationLocation,destinationTime,price)
